/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package polymorphism;

/**
 *
 * @author Iskandar Sarkawi
 */
public class Example1 {

    public static void main(String[] args) {
        Animal a = new Animal();
        Spider b = new Spider();

        a.eat(); //prints yum
        b.eat(); //prints spider-yum

        //'method eat Spider' will overwrite 'method eat Animal'
        a=b;
        System.out.println("");
        a.eat(); //prints spider-yum
        b.eat(); //prints spider-yum
    }

}
